home *** CD-ROM | disk | FTP | other *** search
- {$A+,B-,D-,E-,F-,G-,I-,L-,N-,O-,P-,Q-,R-,S+,T-,V+,X+,Z-}
- {$APPTYPE CONSOLE}
- program BobSpell;
- uses
- Engine, BobSpDlg, Controls;
-
- const
- MaxNode = 4429;
-
- var
- Nodes: Array[1..MaxNode] of ShortString;
- Words,i,j: Integer;
- Str: ShortString;
- IndexFile: Text;
-
- function IndexOf(const Name: ShortString): Integer;
- var
- Max,Min,Tmp: Integer;
- begin
- Result := 0;
- Min := 1;
- Max := MaxNode;
- repeat
- Tmp := (Min + Max) div 2;
- if Nodes[Tmp] < Name then Min := Tmp
- else
- if Nodes[Tmp] > Name then Max := Tmp
- else
- Result := Tmp
- until ((Max - Min) <= 1) or (Result > 0)
- end {IndexOf};
-
- begin
- Assign(IndexFile,'wordlist');
- Reset(IndexFile);
- Words := 0;
- while not eof(IndexFile) do
- begin
- Inc(Words);
- readln(IndexFile,Nodes[Words])
- end;
- Close(IndexFile);
-
- with TFormBobSpell.Create(nil) do
- try
- write('Give word to spell-check: ');
- readln(Str);
- writeln;
- i := IndexOf(Str);
- if i > 0 then writeln('Exact Match at wordlist position ',i)
- else
- begin
- i := 0;
- ListBoxSuggestions.Items.Clear;
- EditFrom.Text := Str;
- EditTo.Text := Str;
- repeat
- Inc(i);
- j := Diff(Str,Nodes[i]);
- if j = 1 then
- ListBoxSuggestions.Items.Add(Nodes[i])
- until (i >= Words) or (j = 0);
- if j = 0 then writeln('Match at ',i,': ',Nodes[i])
- else
- begin
- if ShowModal = mrOk then
- begin
- case Action of
- Ignore: writeln('Ignoring ',Str);
- IgnoreAll: writeln('Ignore All ',Str);
- Replace: writeln('Replace ',Str,' with ',EditTo.Text);
- ReplaceAll: writeln('Replace All ',Str,' with ',EditTo.Text);
- Add: writeln('Add ',Str,' to wordlist');
- else writeln('No Action'); {None}
- end
- end
- else
- writeln('No Action')
- end
- end
- finally
- Free
- end
- end.
-